package fdq.mapper;

import fdq.entity.Feature;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

public interface FeatureMapper {
    //查找全部特征
    @Select("select * from features")
    Feature[] selectAllFeatures();
    //查找某个动物的全部特征
    @Select("select * from features where fid in (select feature from rules where result=#{aid} and isanimal=1)")
    ArrayList<Feature> selectFeatureByAnimal(int aid);



    //根据一个特征推理特征(单条件规则）
    @Select("select * from features where fid in (select result from rules where feature=#{fid} and isanimal=0 and single=1)")
    ArrayList<Feature> selectFeaturesByOneFeature(int fid);

    //根据多个特征推理一个特征（多条件规则）
    @Select("select * from features where fid in (select result from rules where feature=#{fid} and isanimal=0 and single=0)")
    ArrayList<Feature> selectFeaturesByFeatures(int fid);

    //根据结论获取多前提
    @Select("select * from features where fid in (select feature from rules where result=#{rid} and isanimal=0 and single=0)")
    ArrayList<Feature> selectFeaturesByResult(int rid);

    //结论获取单前提
    @Select("select * from features where fid in (select feature from rules where result=#{rid} and isanimal=0 and single=1)")
    ArrayList<Feature> selectOneFeatureByResult(int rid);


    @Select("select feature from features where fid=#{fid}")
    String selectFeatureByFid(int fid);
}
